package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmBenCaoGangMu;
import com.ruoyi.web.admin.service.ITdmBenCaoGangMuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 本草纲目Controller
 * 
 * @author ly
 * @date 2022-03-10
 */
@RestController
@RequestMapping("/admin/tdm_ben_cao_gang_mu")
public class TdmBenCaoGangMuController extends BaseController
{
    @Autowired
    private ITdmBenCaoGangMuService tdmBenCaoGangMuService;

    /**
     * 查询本草纲目列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_ben_cao_gang_mu:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmBenCaoGangMu tdmBenCaoGangMu)
    {
        startPage();
        List<TdmBenCaoGangMu> list = tdmBenCaoGangMuService.selectTdmBenCaoGangMuList(tdmBenCaoGangMu);
        return getDataTable(list);
    }

    /**
     * 导出本草纲目列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_ben_cao_gang_mu:export')")
    @Log(title = "本草纲目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmBenCaoGangMu tdmBenCaoGangMu)
    {
        List<TdmBenCaoGangMu> list = tdmBenCaoGangMuService.selectTdmBenCaoGangMuList(tdmBenCaoGangMu);
        ExcelUtil<TdmBenCaoGangMu> util = new ExcelUtil<TdmBenCaoGangMu>(TdmBenCaoGangMu.class);
        util.exportExcel(response, list, "本草纲目数据");
    }

    /**
     * 获取本草纲目详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_ben_cao_gang_mu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(tdmBenCaoGangMuService.selectTdmBenCaoGangMuById(id));
    }

    /**
     * 新增本草纲目
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_ben_cao_gang_mu:add')")
    @Log(title = "本草纲目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmBenCaoGangMu tdmBenCaoGangMu)
    {
        return toAjax(tdmBenCaoGangMuService.insertTdmBenCaoGangMu(tdmBenCaoGangMu));
    }

    /**
     * 修改本草纲目
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_ben_cao_gang_mu:edit')")
    @Log(title = "本草纲目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmBenCaoGangMu tdmBenCaoGangMu)
    {
        return toAjax(tdmBenCaoGangMuService.updateTdmBenCaoGangMu(tdmBenCaoGangMu));
    }

    /**
     * 删除本草纲目
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_ben_cao_gang_mu:remove')")
    @Log(title = "本草纲目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(tdmBenCaoGangMuService.deleteTdmBenCaoGangMuByIds(ids));
    }
}
